<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">


<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <title th:text="${session.language['acv-title']}"></title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>

    <link href="../static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="../static/css/font-awesome.css?v=4.4.0" rel="stylesheet"/>

    <!-- Data Tables -->
    <link href="../static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet"/>
    <link href="../static/css/animate.css" rel="stylesheet"/>
    <link href="../static/css/style.css?v=4.1.0" rel="stylesheet"/>
    <link href="../static/css/plugins/switchery/switchery.css" rel="stylesheet"/>
    <link href="../static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>

</head>

<body class="gray-bg">
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-12">
        <h2 th:text="${session.language['acv-title']}"></h2>
        <ol class="breadcrumb">
            <li>
                <span th:text="${session.language['manage-title']}"></span>
            </li>
            <li>
                <strong th:text="${session.language['acv-title']}"></strong>
            </li>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 th:text="${session.language['acv-title']}"></h5>
                </div>
                <div class="ibox-content">
                    <a href="/acv-edit/add">
                        <button class="btn btn-info" type="button">
                            <i class="fa fa-paste"></i>
                            <span th:text="${session.language['add']}"></span>
                        </button>
                    </a>
                    <br/>
                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th th:text="${session.language['application-id']}"></th>
                            <th th:text="${session.language['application-name']}"></th>
                            <th th:text="${session.language['config-id']}"></th>
                            <th th:text="${session.language['config-name']}"></th>
                            <th th:text="${session.language['version-id']}"></th>
                            <th th:text="${session.language['version-name']}"></th>
                            <th th:text="${session.language['operation']}"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:if="${#lists.isEmpty(acvs)}">
                            <td colspan="7" style="color: gray" th:text="${session.language['no-record']}"></td>
                        </tr>
                        <tr class="gradeX" th:each="acv : ${acvs}">
                            <td th:text="${acv.application.id}"></td>
                            <td th:text="${acv.application.name}"></td>
                            <td th:text="${acv.config.id}"></td>
                            <td th:text="${acv.config.name}"></td>
                            <td th:text="${acv.version.id}"></td>
                            <td th:text="${acv.version.name}"></td>
                            <td>
                                <a th:href="@{acv-edit/edit(application=${acv.application.id}, config=${acv.config.id}, version=${acv.version.id})}">
                                    <button class="btn btn-success btn-xs" type="button"
                                            style="background-color: #1AB394">
                                        <i class="fa fa-plus"></i>
                                        <span th:text="${session.language['edit']}"></span>
                                    </button>
                                </a>
                                <button class="btn btn-info btn-xs view" type="button"
                                        th:attr="data-application-id=${acv.application.id}, data-application-name=${acv.application.name},
                                        data-config-id=${acv.config.id}, data-config-name=${acv.config.name},
                                        data-version-id=${acv.version.id}, data-version-name=${acv.version.name}">
                                    <i class="fa fa-eye"></i>
                                    <span th:text="${session.language['view']}"></span>
                                </button>
                                <button class="btn btn-danger btn-xs delete" type="button"
                                        th:attr="data-application-id=${acv.application.id},
                                        data-config-id=${acv.config.id}, data-version-id=${acv.version.id}">
                                    <i class="fa fa-trash-o"></i>
                                    <span th:text="${session.language['delete']}"></span>
                                </button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="../static/js/jquery.min.js?v=2.1.4"></script>
<script src="../static/js/bootstrap.min.js?v=3.3.6"></script>

<script src="../static/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="../static/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="../static/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<script src="../static/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="../static/js/plugins/switchery/switchery.js"></script>
<script src="../static/js/plugins/cropper/cropper.min.js"></script>
<!-- Bootstrap table -->
<script src="../static/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="../static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="../static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<!-- Sweet alert -->
<link href="../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet"/>
<script src="../static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script th:inline="javascript">
    $(document).ready(function () {
        $('.view').click(function () {
            /*<![CDATA[*/
            var viewTitle = [[${session.language['acv-title']}]] + " " + [[${session.language['view']}]];

            var applicationIdTitle = [[${session.language['application-id']}]];
            var applicationNameTitle = [[${session.language['application-name']}]];
            var configIdTitle = [[${session.language['config-id']}]];
            var configNameTitle = [[${session.language['config-name']}]];
            var versionIdTitle = [[${session.language['version-id']}]];
            var versionNameTitle = [[${session.language['version-name']}]];
            /*]]>*/

            var applicationId = $(this).data("application-id");
            var applicationName = $(this).data("application-name");
            var configId = $(this).data("config-id");
            var configName = $(this).data("config-name");
            var versionId = $(this).data("version-id");
            var versionName = $(this).data("version-name");
            swal({
                title: viewTitle,
                text:
                '<table border="0px" width="100%">' +
                '<tr><td align="right">' + applicationIdTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + applicationId + '</span></td></tr>' +
                '<tr><td align="right">' + applicationNameTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + applicationName + '</span></td></tr>' +
                '<tr><td align="right">' + configIdTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + configId + '</span></td></tr>' +
                '<tr><td align="right">' + configNameTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + configName + '</span></td></tr>' +
                '<tr><td align="right">' + versionIdTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + versionId + '</span></td></tr>' +
                '<tr><td align="right">' + versionNameTitle + '</td><td>：</td><td align="left"><span style="color: #c7264e;background-color: #f9f2f4;">' + versionName + '</span></td></tr>' +
                '</table>',
                html: true
            });
        });

        $('.delete').click(function () {
            /*<![CDATA[*/
            var applicationId = [[${session.language['application-id']}]];
            var configId = [[${session.language['config-id']}]];
            var versionId = [[${session.language['version-id']}]];

            var deleteTitle = [[${session.language['delete-title']}]];
            var deleteTip = [[${session.language['delete-tip']}]];
            var deleteName = [[${session.language['delete-name']}]];

            var deleteSuccess = [[${session.language['delete-success']}]];
            var deleteSuccessTip = [[${session.language['delete-success-tip']}]];
            var deleteFailure = [[${session.language['delete-failure']}]];
            var deleteFailureTip = [[${session.language['delete-failure-tip']}]];
            /*]]>*/

            var application = $(this).data('application-id');
            var config = $(this).data('config-id');
            var version = $(this).data('version-id');
            swal({
                title: deleteTitle,
                text: applicationId + "：" + application + "<br/>" + configId + "：" + config
                + "<br/>" + versionId + "：" + version + "<br/>" + deleteTip,
                type: "warning",
                html: true,
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: deleteName,
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    url: "acv/" + application + "/" + config + "/" + version,
                    type: "DELETE",
                    dataType: "json",
                    success: function (data) {
                        if (data) {
                            swal(deleteSuccess, deleteSuccessTip, "success");
                        } else {
                            swal(deleteFailure, deleteFailureTip, "error");
                        }
                        // window.location.reload();
                    },
                    error: function (e) {
                        var m = e.responseJSON;
                        swal(deleteFailure, "[" + m.status + " - " + m.error + "] " + m.message, "error");
                    }
                });
            });
        });
    });
</script>
</body>
</html>